<?php

if (isset($this->message)) {
	echo $this->message . "<br />\n";
}

?>
<h3>Module Administration</h3>

<h4>Installed Modules</h4>
<form action="<?php echo $this->baseUrl ?>/admin/module" method="POST">
<table cellpadding="2" cellspacing="2" border="1">
	<tr>
		<th>Module</th>
		<th>Version</th>
		<th>Last Update</th>
		<th>Active</th>
		<th>Action</th>
	</tr>
<?php

if (isset($this->records['installed'])) {
	foreach ($this->records['installed'] as $record) {
		$uninstall = '';
        if ($record['active']) {
            $checked = 'checked="checked"';
        } else {
            $checked = '';
			$uninstall = "<a href=\"{$this->baseUrl}/admin/module/uninstall/id/{$record['id']}\">Uninstall</a> |";
        }
		echo "
	<tr>
		<td>{$record['name']}</td>
		<td>{$record['version']}</td>
		<td>{$record['last_update']}</td>
		<td>
			<input type=\"checkbox\" name=\"active_{$record['id']}\" {$checked} />
			<input type=\"hidden\" name=\"hidden_active_{$record['id']}\" {$checked} />
		</td>
		<td>
			{$uninstall}
			<a href=\"{$this->baseUrl}/admin/module/view/id/{$record['id']}\">View</a>
		</td>
	</tr>";
	}
}

?>
</table>
	<input type="submit" name="btnSubmit" value="Submit">
</form>
<br /><br />

<h4>Uninstalled Modules</h4>
<table cellpadding="2" cellspacing="2" border="1">
	<tr>
		<th>Module</th>
		<th>Version</th>
		<th>Action</th>
	</tr>
<?php

if (isset($this->records['uninstalled'])) {
	foreach ($this->records['uninstalled'] as $key=>$record) {		
		echo "
	<tr>
		<td>{$key}</td>
		<td>{$record['version']}</td>		
		<td>
			<a href=\"{$this->baseUrl}/admin/module/install/name/{$record['name']}\">Install</a>
		</td>
	</tr>";
	}
}

?>
</table>